package me.exchange.com.base;

import lombok.Data;
import me.exchange.com.utils.StringUtils;
import org.springframework.data.domain.Sort;

@Data
public class BaseQueryCriteria {

    private String sortType;

    private String sortFiled;

    private Sort sort;

    public Sort getSort(){
        if(StringUtils.isNotBlank(this.getSortType()) && StringUtils.isNotBlank(this.getSortFiled())){
            if ("DESC".equals(this.getSortType())) {
                return  new Sort(Sort.Direction.DESC, this.getSortFiled());
            }else{
                return new Sort(Sort.Direction.ASC, this.getSortFiled());
            }
        }else{
            return new Sort(Sort.Direction.DESC, "cAdminTime");
        }
    }
}
